Skip to content

[CDRIVER-5961] [CDRIVER-2086] Renaming of binaries, packages, and install paths #1965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

vector-of-bool
Copy link
Contributor

@vector-of-bool vector-of-bool commented Mar 30, 2025

Refer: CDRIVER-5961

This is a follow-up to #1955 which renames many files and packages in preparation for the 2.x updates.

Summary

Renames

This changeset renames 1 the following things:

  • The library filenames:
    • libmongoc-1.0.so.0.0.0 -> libmongoc<major>.so.<major>.<minor>.<patch>
    • libmongoc-static-1.0.a -> libmongoc<major>.a
    • (The same renames for libbson)
    • Window's DLL implibs now have a .dll.lib extension instead of just .lib. This is required to prevent filename collisions, but is also a great help when trying to figure out what's an implib and what's an actual static library archive.
  • pkg-config files:
    • libmongoc-1.0 -> mongoc<major>
    • libbson-1.0 -> bson<major>
  • The CMake targets, bson_static, mongoc_shared, etc. have not been renamed, but in-project aliases (bson::static, mongoc::shared) have been added to match the export names of those targets in the CMake package files. References to the internal targets should use the new name whenever possible.
  • Headers are now installed in a fully-qualified subdirectory of the CMAKE_INSTALL_INCLUDEDIR (e.g. bson-<major>.<minor>.<patch>.

Removals

The following items have been removed:

  • The bson-1.0 and mongoc-1.0 CMake config-file packages are completely removed. We now rely on the config-file packages that were added in [CDRIVER-5931] New forward-compatible CMake package files #1955, which now own the exported CMake targets directly.
  • CMake code for Apple frameworks has been dropped. This isn't strictly related to the overall ticket, but was just low-hanging fruit for something that was untested and is likely never used. This also removed the .modulemap files.
  • The libmongoc-ssl-1.0 pkg-config file is deleted.
  • Several installation tests were removed, as they are extremely verbose, fragile to version changes, and insufficient for anything other than basic checks.

Other Bits

  • CTest cases were added for building a project using pkg-config to import the project. There have been tests for this for a while, but they turn out to be extremely fragile to file renaming, and ran very slowly.
  • Test cases have been modified and rewritten to inspect the VERSION_CURRENT to know the names of packages and files that will be installed. This will be required for a smooth transition when the major version is bumped.
  • The install infix for CMake config-file packages is controlled with MONGO_C_DRIVER_INSTALL_CMAKEDIR. This is based on the GNUInstallDirs variables. The package directories are further controllable with BSON_INSTALL_CMAKEDIR and MONGOC_INSTALL_CMAKEDIR, which default to <prefix>/<infix>/<package-name>-<version>.

Pending

The following open questions remain:

  1. We install a mongoc-stat binary to <prefix>/bin. If we support installing more than one major version, then major versions will fight over who owns this file. Should rename to mongoc<major>-stat? mongoc-static-<major>? Something else?
  2. We install some docs/license components to <prefix>/share/mongo-c-driver. Same issue as above: Multiple major versions will fight over who owns this directory. Maybe tweak to <prefix>/share/mongo-c-driver/<verison>?

Footnotes

  1. Names subject to bikeshedding.

These use the TestProject module to define test
cases that run a CMake build, but that CMake project
uses `pkg-config` to import the libraries rather than `find_package`.
This allows us to test `pkg-config` while relying on CMake to do the
heavy lifting around compiler detection and search path handling.
When building a TestProject, we want to set CMAKE_PREFIX_PATH to point
to the directory that received the parent project installation.
Previously, pkg-config generated a `-l` with a library stem, and it
would only coincidentally name a static library with a `.a` suffix.
Instead, for static libraries, specify the path to the actual static
library archive file. Only rely on `-l` searching for shared libraries.
This change is BREAKING and changes the names of generated files for
libbson (libmongoc TBD).

- Headers are installed in a directory qualified by the project version.
- The generated dynamic library has a property version suffix now (instead of
  0.0.0).
- We set the SOVERSION property to generate a new SONAME for the emitted bson
  library.
- The bson-1.0 CMake packages are removed.
- The pkg-config files are now named `bson1` and `bson1-static`.
- Both the static and dynamic library file stems are now `libbson1` (no
  `-static` suffix).
- The project now imports the system libbson using the name "bson" instead
  of `bson-1.0` (as well as the generated mongoc config-file package)
@vector-of-bool vector-of-bool marked this pull request as ready for review March 31, 2025 03:51
Copy link
Contributor

@rcsanchez97 rcsanchez97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with two small typo fixes.

# by setting HINTS and NO_DEFAULT_PATH
get_filename_component(parent_dir "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY)
find_dependency(bson-1.0 HINTS ${parent_dir} NO_DEFAULT_PATH)
# Import the target files that will be install alongside this file. Only the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Import the target files that will be install alongside this file. Only the
# Import the target files that will be installed alongside this file. Only the

set(CMAKE_MODULE_PATH "${__prev_path}")
endif()

# Import the target files that will be install alongside this file. Only the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Import the target files that will be install alongside this file. Only the
# Import the target files that will be installed alongside this file. Only the

@kevinAlbs
Copy link
Collaborator

Should rename to mongoc<major>-stat? mongoc-static-<major>? Something else?

I vote mongoc<major>-stat (suffix version to mongoc to signal it is for C driver 2.0).

Maybe tweak to <prefix>/share/mongo-c-driver/<verison>?

Adding a <version> subdirectory SGTM.

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor suggestions. I very much like the new naming scheme. I expect including the API version in the filename and include directories will help users quickly identify the version installed. The test speed-ups are also appreciated.

@kevinAlbs kevinAlbs changed the title [CDRIVER-5931] Renaming of binaries, packages, and install paths [CDRIVER-5961] Renaming of binaries, packages, and install paths Apr 1, 2025
@kevinAlbs kevinAlbs changed the title [CDRIVER-5961] Renaming of binaries, packages, and install paths [CDRIVER-5961] [CDRIVER-2086] Renaming of binaries, packages, and install paths Apr 1, 2025
@kevinAlbs kevinAlbs merged commit 09018b8 into mongodb:master Apr 1, 2025
33 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants